<!-- ************************************************************************************************************ -->
<!-- fileName          : UpdateAdminUser.jsp 																	  -->
<!-- author            : 马文军 																					  --> 
<!-- createDate        : 2015/05/09 																			  -->
<!-- summary           : admin端  “修改账号” 后台逻辑 															  		  -->
<!-- modifiedBy        : 马文军																				      -->
<!-- ************************************************************************************************************ -->

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>UpdateAdminUser</title>
<style type="text/css">

</style>

</head>
<body>
<%
	//设置请求的字符编码以支持中文
	request.setCharacterEncoding ("utf-8");

	//从请求页面获取表单参数
    String username = request.getParameter("username");
    System.out.println("更新管理员账号");

     
	//从web.xml文件获取全局参数
	String drv=config.getServletContext().getInitParameter("DBDriver");
	String url=config.getServletContext().getInitParameter("DBURL");
	String uid=config.getServletContext().getInitParameter("DBUser");
	String pwd=config.getServletContext().getInitParameter("DBPass");
	
    //构建SQL字符串和JDBC对象
    
	String strSQL1 = "update immie0_immi.user set username=? where id=1 ";
	Connection conn = null;
	PreparedStatement pstmt = null;	
	
	try {
		Class.forName(drv).newInstance();
		conn = DriverManager.getConnection(url,uid,pwd);
		pstmt = conn.prepareStatement(strSQL1);
		pstmt.setString(1, username);

		pstmt.executeUpdate();  
      
		response.sendRedirect("./admin_adminuser.jsp?result=ok");
	} catch (ClassNotFoundException e) {
		e.printStackTrace();
	} catch (InstantiationException e) {
	    e.printStackTrace();
	} catch (IllegalAccessException e) {
		e.printStackTrace();
	} catch (SQLException e) {
		e.printStackTrace();
	} 
	finally {
		if (pstmt != null) {
			pstmt.close();
			pstmt = null;
		}		
		if (conn != null) {
			conn.close();
			conn = null;
		}
	}
%>
</body>
</html>